﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ChangePass : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] == null) {
            Response.Redirect("~/login.aspx");
        }
    }    
    protected void changepass_Click(object sender, EventArgs e)
    {
        if (Session["username"] != null)
        {
            String CurrentPass = TextBoxPassword.Text;
            String newPass = NewPass.Text;
            String Username = retypenewpass.Text;

            DatabaseProcess dp = new DatabaseProcess();
            String query = "update User_ set Password_ ='" + newPass + "' WHERE Email ='" + Session["username"] + "' AND Password_ = '" + CurrentPass + "'";
            int num = dp.ConnectDataBaseReturnInt(query);
            if (num > 0)
            {
                labelchange.Text = "changepass successfully";
            }
            else
            {
                Response.Write("error!!!");
            }
        }
        else
        {
            Response.Redirect("~/login.aspx");
        }
    }
}